package com.itheima.controller;

import com.itheima.pojo.Result;
import com.itheima.pojo.RewardItems;
import com.itheima.service.RewardItemsService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.Date;

/**
 * @Author: zengxz
 * @Description: 奖励机制（商品展示）
 * @DateTime: 2024/9/30 14:02
 **/


@RestController
@RequestMapping("/reward")
@Slf4j
public class RewardItemsController {
    @Resource
    private RewardItemsService rewardItemsService;


    //添加(无传id)/修改(有传id)商品
    @PostMapping("/saveOrUpdate")
    public Result<String> saveOrUpdate(@RequestBody RewardItems rewardItems){
        //设置创建、修改、逻辑删除=0   注：0是未删除、1 是已删除
        rewardItems.setCreatedTime(LocalDateTime.now());
        rewardItems.setUpdatedTime(LocalDateTime.now());
        boolean b = rewardItemsService.saveOrUpdate(rewardItems);
        return b ? Result.success("添加成功") : Result.error("添加失败");
    }

    //删除商品
    @DeleteMapping
    public Result<String> delect(@RequestParam Integer itemId){
        return Result.success();
    }

    //查询商品信息

    //查询商品列表

}
